package com.olt.config;
import cn.hutool.core.util.StrUtil;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;

import org.springframework.stereotype.Component;


@Component
public class JpaConfig extends PhysicalNamingStrategyStandardImpl {
    public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) {
        // 将表名全部转换成大写
        String tableName = name.getText();
        return name.toIdentifier(tableName);
    }
    public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) {
        String text = StrUtil.toUnderlineCase(name.getText());
        return new Identifier(text, name.isQuoted());

    }

}
